import { createSlice } from '@reduxjs/toolkit';
import { storage } from '@/utils';

const initialState = {
    cityList: storage.getItem(storage.keys.CITY_LIST) || [],
    tPostInfo: storage.getItem(storage.keys.WORK_CONTENT) || {},
};

const form = createSlice({
    name: 'form',
    initialState,
    reducers: {
        setCityList: (state, action) => {
            state.cityList = action.payload;
        },
        setTPostInfo: (state, action) => {
            state.tPostInfo = action.payload;
            storage.setItem(storage.keys.WORK_CONTENT, action.payload);
        },
    },
});

export const { setCityList, setTPostInfo } = form.actions;
export default form.reducer;
